﻿using LibreHardwareMonitor.Hardware;
using System;
using System.ComponentModel;
using System.Windows;

namespace WWLauncher.ViewModel
{
    public class MonitorViewModel : INotifyPropertyChanged
    {
        private float cpuUsage;
        private float gpuUsage;
        private float memoryUsage;
        private int cpuClock;
        private bool onTop = true;
        private bool isAdministrator;
        private Visibility administratorVisibility = Visibility.Collapsed;
        private Visibility frequencyVisibility;
        private float cpuTemperature;
        private float gpuTemperature;
        private float cpuFan;
        private Visibility btnColVisibility = Visibility.Collapsed;
        private int oneColumnDefinition = 30;
        private string onTopSource = "/Resource/Icon/置顶.ico";
        private float sending;
        private float receive;
        private string sendingText;
        private string receiveText;

        public MonitorViewModel()
        {
        }
        /// <summary>
        /// 置顶
        /// </summary>
        public bool OnTop
        {
            get => onTop;
            set { onTop = value; OnPropertyChanged(nameof(OnTop)); }
        }
        public float MemoryUsage
        {
            get => memoryUsage;
            set { memoryUsage = value; OnPropertyChanged(nameof(MemoryUsage)); }
        }

        public float CpuUsage
        {
            get => cpuUsage;
            set
            {
                cpuUsage = value; OnPropertyChanged(nameof(CpuUsage));
            }
        }

        public float GpuUsage
        {
            get => gpuUsage;
            set { gpuUsage = value; OnPropertyChanged(nameof(GpuUsage)); }
        }

        public int CpuClock
        {
            get => cpuClock;
            set { cpuClock = value; OnPropertyChanged(nameof(CpuClock)); }
        }

        public float CpuTemperature
        {
            get => cpuTemperature;
            set { cpuTemperature = value; OnPropertyChanged(nameof(CpuTemperature)); }
        }

        public float GpuTemperature
        {
            get => gpuTemperature;
            set { gpuTemperature = value; OnPropertyChanged(nameof(GpuTemperature)); }
        }
        public bool IsAdministrator
        {
            get => isAdministrator;
            set
            {
                isAdministrator = value;
                OnPropertyChanged(nameof(IsAdministrator));
            }
        }

        public Visibility AdministratorVisibility
        {
            get => administratorVisibility;
            set
            {
                administratorVisibility = value;
                OnPropertyChanged(nameof(AdministratorVisibility));
            }
        }
        public Visibility BtnColVisibility
        {
            get => btnColVisibility;
            set
            {
                btnColVisibility = value;
                OnPropertyChanged(nameof(BtnColVisibility));
            }
        }
        public Visibility FrequencyVisibility
        {
            get => frequencyVisibility;
            set
            {
                frequencyVisibility = value;
                OnPropertyChanged(nameof(FrequencyVisibility));
            }
        }

        public float CpuFan
        {
            get => cpuFan;
            set
            {
                cpuFan = value;
                OnPropertyChanged(nameof(CpuFan));
            }
        }
        public int OneColumnDefinition
        {
            get => oneColumnDefinition;
            set
            {
                oneColumnDefinition = value;
                OnPropertyChanged(nameof(OneColumnDefinition));
            }
        }
        public string OnTopSource
        {
            get => onTopSource;
            set
            {
                onTopSource = value;
                OnPropertyChanged(nameof(OnTopSource));
            }
        }

        public float Receive
        {
            get => receive;
            set
            {
                receive = value;
                OnPropertyChanged(nameof(Receive));
            }
        }
        public string ReceiveText
        {
            get => receiveText;
            set
            {
                receiveText = value;
                OnPropertyChanged(nameof(ReceiveText));
            }
        }
        public float Sending
        {
            get => sending;
            set
            {
                sending = value;
                OnPropertyChanged(nameof(Sending));
            }
        }
        public string SendingText
        {
            get => sendingText;
            set
            {
                sendingText = value;
                OnPropertyChanged(nameof(SendingText));
            }
        }
        [field: NonSerialized()]
        public event PropertyChangedEventHandler PropertyChanged;
        private void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}